﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using TuringVM.Core;
using TuringVM.Esoteric;
using TuringVM.Esoteric.Preprocessors;
using TuringVM.Debug;

namespace TuringVM.Esoteric.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            MachineSettings settings = new MachineSettings() { AllowDebugging = true };
            CommandSet commands = Esoteric.GetDefaultCommandSet();

            var vm = new Machine(commands, settings);
            var dbg = new Debugger();
            vm.Debugger = dbg.Step;

            var preprocessor = new BrainfuckPreprocessor();
            var compiler = new EsotericCompiler();

            string source = File.ReadAllText("test.bf");
            string ilCode = preprocessor.Process(source);
            byte[] bytecode = compiler.Compile(ilCode);

            vm.Load(bytecode);
            vm.Run();

            Console.ReadKey();
        }
    }
}
